.TH std::is_pointer_interconvertible_base_of 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::is_pointer_interconvertible_base_of \- std::is_pointer_interconvertible_base_of

.SH Synopsis
   Defined in header <type_traits>
   template< class Base, class Derived >        \fI(since C++20)\fP
   struct is_pointer_interconvertible_base_of;

   If Derived is unambiguously derived from Base and every Derived object is
   pointer-interconvertible with its Base subobject, or if both are the same non-union
   class (in both cases ignoring cv-qualification), provides the member constant value
   equal to true. Otherwise value is false.

   If both Base and Derived are non-union class types, and they are not the same type
   (ignoring cv-qualification), Derived shall be a complete type; otherwise the
   behavior is undefined.

   If the program adds specializations for std::is_pointer_interconvertible_base_of or
   std::is_pointer_interconvertible_base_of_v, the behavior is undefined.

.SH Member constants

            true if Derived is unambiguously derived from Base and every Derived object
   value    is pointer-interconvertible with its Base subobject, or if both are the
   \fB[static]\fP same non-union class (in both cases ignoring cv-qualification), false
            otherwise
            \fI(public static member constant)\fP

.SH Member functions

   operator bool converts the object to bool, returns value
                 \fI(public member function)\fP
   operator()    returns value
   \fI(C++14)\fP       \fI(public member function)\fP

.SH Member types

   Type       Definition
   value_type bool
   type       std::integral_constant<bool, value>

.SH Notes

   std::is_pointer_interconvertible_base_of_v<T, U> may be true even if T is a private
   or protected base class of U.

   Let

     * U be a complete object type,
     * T be a complete object type with cv-qualification not less than U,
     * u be any valid lvalue of U,

   reinterpret_cast<T&>(u) always has well-defined result if
   std::is_pointer_interconvertible_base_of_v<T, U> is true.

   If T and U are not the same type (ignoring cv-qualification) and T is a
   pointer-interconvertible base class of U, then both std::is_standard_layout_v<T> and
   std::is_standard_layout_v<U> are true.

   If T is standard layout class type, then all base classes of T (if any) are
   pointer-interconvertible base class of T.

         Feature-test macro            Value    Std                       Feature
                                                      Pointer-interconvertibility traits:
__cpp_lib_is_pointer_interconvertible 201907L (C++20)   * std::is_pointer_interconvertible_base_of,
                                                        * std::is_pointer_interconvertible_with_class

.SH Example


// Run this code

 #include <type_traits>

 struct Foo {};

 struct Bar {};

 class Baz : Foo, public Bar { int x; };

 class NonStdLayout : public Baz { int y; };

 static_assert(std::is_pointer_interconvertible_base_of_v<Bar, Baz>);
 static_assert(std::is_pointer_interconvertible_base_of_v<Foo, Baz>);
 static_assert(not std::is_pointer_interconvertible_base_of_v<Baz, NonStdLayout>);
 static_assert(std::is_pointer_interconvertible_base_of_v<NonStdLayout, NonStdLayout>);

 int main() {}

.SH See also

   is_base_of         checks if a type is derived from the other type
   \fI(C++11)\fP            \fI(class template)\fP
   is_empty           checks if a type is a class (but not union) type and has no
   \fI(C++11)\fP            non-static data members
                      \fI(class template)\fP
   is_standard_layout checks if a type is a standard-layout type
   \fI(C++11)\fP            \fI(class template)\fP
